package com.jinke.api.modules.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jinke.api.modules.user.model.UmsAdminPriceRuleRelation;
import com.jinke.api.modules.user.mapper.UmsAdminPriceRuleRelationMapper;
import com.jinke.api.modules.user.service.UmsAdminPriceRuleRelationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户与自定义价格关系设置表 服务实现类
 * </p>
 *
 * @author husuruo
 * @since 2024-07-17
 */
@Service
public class UmsAdminPriceRuleRelationServiceImpl extends ServiceImpl<UmsAdminPriceRuleRelationMapper, UmsAdminPriceRuleRelation> implements UmsAdminPriceRuleRelationService {

    /**
     * 查询用户是否绑定了serviceCode对应的价格表关系
     * @param userId
     * @param serviceCode
     * @return
     */
    @Override
    public long getIsBinding(Integer userId, String serviceCode) {
        //查此人是否绑定了这个serviceCode对应的
        LambdaQueryWrapper<UmsAdminPriceRuleRelation> q=new LambdaQueryWrapper<>() ;
        q.eq(serviceCode!=null,UmsAdminPriceRuleRelation::getServiceCode, serviceCode);
        q.eq(UmsAdminPriceRuleRelation::getUserId, userId);
        long count = count(q);
        return count;
    }
}
